<script setup lang="ts">
import HelloWorld from "./components/HelloWorld.vue";
import TheWelcome from "./components/TheWelcome.vue";
import { useStore } from "vuex";
import {ref} from "vue";

interface normalObj {
  name: string,
  age: number,
  job:string,
  hobbies:string[]
}

const obj: normalObj = {
  name: "张三",
  age: 20,
  job:"前端开发工程师",
  hobbies:["打游戏","看电影"]
}

// 实现 pick 功能 , 只需要 name 和 age 属性
interface easyObj {
  name: string,
  age: number
}

type easyObjType = Pick<normalObj, "name" | "age">;

const obj2: easyObjType = {
  name: "张三",
  age: 20
}


const store = useStore();
const increment = () => {
  // 只能通过 commit 函数来触发 mutaitions 中定义的两个函数 increment 和 decrement
  store.commit("increment");
};
const decrease = () => {
  store.commit("decrement");
};

</script>

<template>
  <header>
    <!-- <img alt="Vue logo" class="logo" src="./assets/logo.svg" width="125" height="125" />

    <div class="wrapper">
      <HelloWorld msg="You did it!" />
    </div> -->
  </header>

  <main>
    <!-- <TheWelcome /> -->
    <h1>数量是：{{ $store.state.count }}</h1>
    <button @click="increment">+100</button>
    <button @click="decrease">-100</button>

    <h1>姓名信息：{{ obj.name }}</h1>
  </main>
</template>

<style scoped>
header {
  line-height: 1.5;
}

.logo {
  display: block;
  margin: 0 auto 2rem;
}

@media (min-width: 1024px) {
  header {
    display: flex;
    place-items: center;
    padding-right: calc(var(--section-gap) / 2);
  }

  .logo {
    margin: 0 2rem 0 0;
  }

  header .wrapper {
    display: flex;
    place-items: flex-start;
    flex-wrap: wrap;
  }
}
</style>
